package com.itgungnir.designpattern.observer.custom;

/**
 * 主题对象（被观察者）
 */
public abstract class Subject {
	protected String name;
	protected Object thing;

	abstract void addObserver(Observer observer);

	abstract void removeObserver(Observer observer);

	abstract void notifyObservers();

	public void setThing(Object thing) {
		this.thing = thing;
		System.out.println(this.name + "发布了一条消息：" + thing.toString());
		notifyObservers();
	}
}